/* TABLE A3 */
use "C:\Users\Public\Documents\ImmPanelRevis19\ImmPanelRevis19\donnees\indiv_dispm.dta", clear
contract nninouv an
drop _freq
contract nninouv
rename _freq nyear
save "C:\Users\Public\Documents\ImmPanelRevis19\ImmPanelRevis19\donnees\nyear.dta", replace



capture program drop rapido
program define rapido
version 11
syntax, period(string)

keep if homme==1
drop if dep=="2A" | dep=="2B"

/* ELIMINATE WORKERS ONLY OBSERVED ONCE in 40 years => probable coding error */
joinby nninou using "C:\Users\Public\Documents\ImmPanelRevis19\ImmPanelRevis19\donnees\nyear.dta", unm(m)
drop _merge
drop if nyear==1


gen first=(age>=25 & age<=50)
egen time=group(an)
egen nindiv=group(nninouv)
drop if missing(nindiv)
xtset nindiv time
tab first an
gen twice=(first==1 & !missing(F.time))

/* all workers */
gen all=1
/* blue collar dummy */
gen ouv=(cs2h=="62" | cs2h=="63" | cs2h=="64" | cs2h=="65" | cs2h=="67" | cs2h=="68" | cs2h=="69" )
gen bc=(ouv==1)

/****************************************/
/* ouvriers qualitifés et non qualifiés */
/****************************************/
gen qual=(cs2_anc=="60" | cs2_anc=="61" ///
| cs2=="62" | cs2=="63"| cs2=="64"| cs2=="65")
/* low skilled BLUE COLLARD */
gen bcnq=bc*(1-qual)
/* Skilled BLUE COLLARD */
gen bcq=bc*(qual)

/* Managers */
gen cad=(cs2h=="23" | cs2h=="31" | cs2h=="33" | cs2h=="34" | cs2h=="35" | cs2h=="37" | cs2h=="38")

/* Technicians */
gen tec=(cs2h=="42" | cs2h=="43" | cs2h=="44" | cs2h=="45" | cs2h=="46" | cs2h=="47" )

/* clerk */
gen clrk=(cs2h=="46")

gen occup="bcq" if bcq
replace occup="bcnq" if bcnq
replace occup="cad" if cad
replace occup="tec/clrk" if tec | clrk

display `anything'
/* PANEL B */
tab twice an if an!=2007 & first & !missing(occup), col
display `anything'

/* PANEL C */
tab  twice occup if an!=2007 & first & !missing(occup), col
end

/* Standard sample */
use "C:\Users\Public\Documents\ImmPanelRevis19\ImmPanelRevis19\donnees\indiv.dta", clear
rapido , period("Standard sample")

/* 3 YEARS SAMPLE */
use "C:\Users\Public\Documents\ImmPanelRevis19\ImmPanelRevis19\donnees\permanent_revis3y.dta", clear
rapido , period("3 YEARS SAMPLE")

/* 5 YEARS SAMPLE */
use "C:\Users\Public\Documents\ImmPanelRevis19\ImmPanelRevis19\donnees\permanent_revis5y.dta", clear
rapido , period("5 YEARS SAMPLE")

